package com.datam.utils;

import java.util.List;
import java.util.Map;

import org.springframework.context.ApplicationContext;

import com.datam.controller.CompanyController;
import com.datam.controller.ContactController;
import com.datam.dao.CompanyContactDAO;
import com.datam.dao.CompanyInfoDAO;
import com.datam.dao.CompanyJkDeviceDAO;
import com.datam.dao.CompanyPkInfoDAO;
import com.datam.dao.CompanyZlDeviceDAO;
import com.datam.dao.ConpanyTxInfoDAO;
import com.datam.dao.YJDAO;
import com.datam.domain.CompanyContactDO;
import com.datam.domain.CompanyInfoDO;
import com.datam.domain.CompanyJkDeviceDO;
import com.datam.domain.CompanyPkInfoDO;
import com.datam.domain.CompanyPkYjDO;
import com.datam.domain.CompanyZlDeviceDO;
import com.datam.domain.ConpanyTxInfoDO;

public class TestUtils {
	
	public static void test(ApplicationContext context){
		companyTest(context);
		Devicetest(context);
		pktest(context);
		txtest(context);
		yj1(context); 
		cc(context); 
	}

	private static void companyTest(ApplicationContext context) {
		CompanyInfoDAO c = context.getBean(CompanyInfoDAO.class);
    	CompanyInfoDO CompanyInfoDO = c.selectCompanyInfoById(1l);
    	CompanyInfoDO.setNAME("testaaaa");
    	CompanyInfoDO.setLEGALORCODE("ddddddddd");
    	CompanyController cc = context.getBean(CompanyController.class);
    	//cc.saveCompanyData(null, null, CompanyInfoDO, "ffff", "rrrr");
    	CompanyInfoDO.setID(null);
    	CompanyInfoDO.setLEGALORCODE("ffqxss11111fgedf");
    	//cc.saveCompanyData(null, null, CompanyInfoDO, "uu", "uu");
		
	}
	
	private static void Devicetest(ApplicationContext context) {
		CompanyJkDeviceDAO c = context.getBean(CompanyJkDeviceDAO.class);
		CompanyJkDeviceDO CompanyInfoDO = c.selectCompanyJkDeviceById(1l);
    	CompanyInfoDO.setNAME("testaaaa");
    	c.updateCompanyJkDeviceById(CompanyInfoDO);
    	
    	CompanyZlDeviceDAO companyZlDeviceDAO = context.getBean(CompanyZlDeviceDAO.class);
    	CompanyZlDeviceDO CompanyZlDeviceDO = companyZlDeviceDAO.selectCompanyZlDeviceById(1L);
    	CompanyZlDeviceDO.setNAME("testaaaa");
    	companyZlDeviceDAO.updateCompanyZlDeviceById(CompanyZlDeviceDO);
    	
		
	}
	
	private static void pktest(ApplicationContext context) {
		CompanyPkInfoDAO companyPkInfoDAO = context.getBean(CompanyPkInfoDAO.class);
		CompanyPkInfoDO companyPkInfoDO = companyPkInfoDAO.selectCompanyPkInfoById(1L);
		companyPkInfoDO.setNAME("testaaaa");
		companyPkInfoDAO.updateCompanyPkInfoById(companyPkInfoDO);
	}
	
	private static void txtest(ApplicationContext context) {
		ConpanyTxInfoDAO companyPkInfoDAO = context.getBean(ConpanyTxInfoDAO.class);
		ConpanyTxInfoDO companyPkInfoDO = companyPkInfoDAO.selectConpanyTxInfoById(1L);
		companyPkInfoDO.setSBXH("testaaaa");
		companyPkInfoDAO.updateConpanyTxInfoById(companyPkInfoDO);
	}
	
	private static void yj1(ApplicationContext context) {
		YJDAO YJDAO = context.getBean(YJDAO.class);
		CompanyPkYjDO c = new CompanyPkYjDO();
		c.setID(1l);
		c.setSCOPE("testaaaaaaa");
		YJDAO.updatepkyjByDo(c);
		YJDAO.updateyj(1L, 1l, "testsaaaa", "1", "99");
		
	}
	
	private static void cc(ApplicationContext context) {
		CompanyContactDAO YJDAO = context.getBean(CompanyContactDAO.class);
		CompanyContactDO companyContactDO = YJDAO.selectCompanyContactById(1l);
		ContactController c = context.getBean(ContactController.class);
		System.out.println(c.saveCompanyContactData( companyContactDO));
		companyContactDO.setID(null);
		companyContactDO.setNAME("TESTFFFF");
		System.out.println(c.saveCompanyContactData(companyContactDO));
	}
	
	
}
